package com.lzs.collection.list.traverse;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class ListFor {
    @SuppressWarnings("all")
    public static void main(String[] args) {
        List list = new LinkedList();
        list.add("Tom");
        list.add("Jack");
        list.add("鱼香肉丝");
        list.add("北京烤鸭");
        //迭代器遍历
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Object next = iterator.next();
            System.out.println(next);
        }
        System.out.println("==========增强for==========");
        for (Object o : list) {
            System.out.println(o);
        }
        System.out.println("==========增强for==========");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

    }
}
